import React, { Component } from 'react';
import LifeChild from '../../components/LifeChild/LifeChild';
class Life extends Component {
    constructor(props) {
        super(props)
        this.state = {
            fmsg: '生命周期父组件的数据',
            flag: true
        }
    }
    changeFlag = () => {
        this.setState({
            flag: false
        })
    }
    render() {
        return (
            <div>
                <h2>生命周期</h2>
                {this.state.flag ? <LifeChild fmsg={this.state.fmsg}></LifeChild> : ''}
                <button onClick={this.changeFlag}>隐藏/卸载组件</button>
            </div>
        );
    }
}

export default Life;